﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace VoltcraftControlInterface
{
    class Pnl       //POLYNOMIAL EDITOR PANEL ANIMATION
    {
        public void openPnl(ref Panel pnl)
        {
            for (int i = -156; i < 32; i += 4)
            {
                pnl.Location = new Point(i, pnl.Location.Y);
                pnl.Update();
                ((MainForm)pnl.GetContainerControl()).Update();
            }
            pnl.Location = new Point(32, pnl.Location.Y);
            pnl.Update();
            ((MainForm)pnl.GetContainerControl()).Update();
        }
        public void closePnl(ref Panel pnl)
        {
            for (int i = 32; i > -156; i -= 8)
            {
                pnl.Location = new Point(i, pnl.Location.Y);
                pnl.Update();
                ((MainForm)pnl.GetContainerControl()).Update();
            }
            pnl.Location = new Point(-156, pnl.Location.Y);
            pnl.Update();
            ((MainForm)pnl.GetContainerControl()).Update();
        }
    }

    class CustomProfessionalColors : ProfessionalColorTable     //TOOLSTRIPS GRADIENTS
    {
        public override Color ToolStripGradientBegin
        { get { return Color.FromArgb(255, Color.LightGray); } }
        public override Color ToolStripGradientMiddle
        { get { return Color.FromArgb(0xFF, 0xE9, 0xE9, 0xE9); } }
        public override Color ToolStripGradientEnd
        { get { return Color.FromArgb(255, Color.White); } }
        public override Color MenuStripGradientBegin
        { get { return Color.Transparent; } }
        public override Color MenuStripGradientEnd
        { get { return Color.Transparent; } }
        public override Color ToolStripBorder
        { get { return Color.Transparent; } }
    }

    [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)]
    public class ToolStripNumberControl : ToolStripControlHost
    {
        public ToolStripNumberControl()
            : base(new NumericUpDown())
        {

        }

        protected override void OnSubscribeControlEvents(Control control)
        {
            base.OnSubscribeControlEvents(control);
            ((NumericUpDown)control).ValueChanged += new EventHandler(OnValueChanged);
        }

        protected override void OnUnsubscribeControlEvents(Control control)
        {
            base.OnUnsubscribeControlEvents(control);
            ((NumericUpDown)control).ValueChanged -= new EventHandler(OnValueChanged);
        }

        public decimal Value
        {
            get
            {
                return NumericUpDownControl.Value;
            }
            set
            {
                NumericUpDownControl.Value = value;
            }
        }

        public override bool Enabled
        {
            get
            {
                return NumericUpDownControl.Enabled;
            }
            set
            {
                NumericUpDownControl.Enabled = value;
            }
        }

        public decimal Maximum
        {
            get
            {
                return NumericUpDownControl.Maximum;
            }
            set
            {
                NumericUpDownControl.Maximum = value;
            }
        }

        public decimal Minimum
        {
            get
            {
                return NumericUpDownControl.Minimum;
            }
            set
            {
                NumericUpDownControl.Minimum = value;
            }
        }
        public event EventHandler ValueChanged;

        public NumericUpDown NumericUpDownControl
        {
            get { return Control as NumericUpDown; }
        }

        public void OnValueChanged(object sender, EventArgs e)
        {
            if (ValueChanged != null)
            {
                ValueChanged(this, e);
            }
        }
    }
}
